<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>测试</title>
    <style type="text/css" media="screen" id="test">
        .div{
            width:300px;
            height:200px;
            border:2px solid blue;
            left:110px;
            padding:10px;
        }
        .dc{
            border:3px solid blue;
            padding:10px;
        }
    </style>
     <script type="text/javascript">
        djConfig = {
            isDebug:false
        }
     </script>
     <!--
    <script src="/dojo/dojo/dojo.js" type="text/javascript"></script>
	<script src="/mydojo/util/autocomplete/autocomplete.js" type="text/javascript"></script>
        -->
         <script src="/dojo/dojo/dojo.js" type="text/javascript"></script>
	<script src="/dojo/dojot/util/AutoComplete.js" type="text/javascript"></script>
    <script type="text/javascript">
        //var dojot = dojot || {};
        var h = 0;
        var w = 0;
        function testAddStyle(){
            dojot.util = {
                _addStyle : (function(){
                    var styleSheet = dojox.html.getDynamicStyleSheet("autocomplete");
                    return function(styleName,styleBody){
                         var styleContent = styleName + " { "+styleBody+" }";
                         dojox.html.insertCssRule(styleName,styleBody,styleSheet);
                    } ;    
                })()
            }
            dojot.util._addStyle(".containter","border:1px solid blue;width:600px;height:200px;position:absolute");
            setTimeout(function(){
                 //var ss = dojot.util._addStyle("div","border:2px solid red;height:200px");
                 //console.log(ss);
            },1000);  
        }
        function testMarginBox( ){
            var marginBox = dojo.marginBox("i1");
            var contentBox = dojo.contentBox("i1");
            console.log(contentBox);
            console.log(marginBox);
            var div = dojo.create("div",null,dojo.body());
            dojo.addClass(div,"containter");
            var top = 0,left = 0;
            if(dojo.isIE === 7){
                tt = getTopAndLeft(dojo.byId("i1"));
                top = tt.top + marginBox.h;
                left = tt.left;
            }else{
                top = marginBox.t + marginBox.h;
                left = marginBox.l;
            }

            dojo.marginBox(div,{t:top,l:left});
            console.log("h00001-->"+h);
             console.log("h00004-->"+marginBox.t);
            console.log("h00002-->"+marginBox.h);
            console.log("h00003-->"+(h+marginBox.h));
          
            
        }
        getTopAndLeft = function(elem){
            var topAndLeft = {};
            var top = 0,left = 0;
            
            var calculator = function(elem){
                if(elem){
                    var elem = dojo.byId("d11");
                    var elemStyle = dojo.style(elem,"style");
                    var borderTopWidth = elemStyle['borderTopWidth'];
                    var borderLeftWidth = elemStyle['borderTopWidth'];
                    top += (elem.offsetTop + borderTopWidth);
                    left += (elem.offsetLeft + borderLeftWidth);
                    elem = elem.offsetParent;
                    calculator(elem)
                }else{
                    return;
                }
            }
            calculator(elem);
            console.log(top);
            topAndLeft.top = top;
            topAndLeft.left = left;
            return topAndLeft;
        }
        function testRequrestServer(){
            var serverUrl = 'http://192.168.1.165:8080/solr/select/?version=2.2&start=0&rows=10&indent=on&wt=json'
            var req = {
                url: serverUrl,
                callbackParamName:'json.wrf',
                content: {
                    q:'orgName:'+"北京大学"
                },
                load: _createSuggestions,
                error: function(err){
                  console.log(err);
                  _createSuggestions();
                }
            };
          var deffered = dojo.io.script.get(req);   
            
        }
        function test1(data){
            console.log(data.response.docs.length);
        }
        function _createSuggestions(data){
             console.log("hehehe");
            console.log(data.response.docs.length);
        }
        dojo.addOnLoad(function(){
            
            //testAddStyle();
            //testMarginBox();
           //testRequrestServer();
           obj = {
                textInput:"orgNameId",
                orgInput:"orgId",
                searchType:"c"
           }
           console.log(dojot);
           //dojo.require("dojot.util.AutoComplete");
          // console.log(dojot.util.autocomplete);
           auto = new dojot.util.AutoComplete(obj);
           auto2 = new dojot.util.AutoComplete({
                textInput:"orgNameId2",
                orgInput:"orgId2"  ,
                searchType:"s"
            });
           console.log("-------------------->"+(auto.cached === auto2.cached));
           
        });
       
    </script>
</head>
<body>
    <div id="d5" class="dc">
                    <div id="d11" style="padding:17px;border:5px solid red;width:400px">
                        <div style="padding:10px;">
                            <h1>选同事</h1>
                            <form action="http://profile.tianji.com/Profile/Find/Colleagues?isNew=true" onsubmit="javascript:return false">
                                 测试orgId的设置:<input name="workId" id="orgId" type="text"/>
                                <br/>
                                <input id="orgNameId" type="text" size="55"/>
                                <input type="submit" value="保存1"/>
                            </form>
                        </div>
                    </div>
                    <div style="padding:17px;border:5px solid blue;width:400px">
                            <h1>选校友</h1>
                            <form action="http://profile.tianji.com/Profile/Find/Colleagues?isNew=true" onsubmit="javascript:return false">
                                 测试orgId的设置:<input name="workId" id="orgId2" type="text"/> 
                                <br/>
                                <input id="orgNameId2" type="text" size="55"/>
                                <input type="submit" value="保存2"/>
                            </form>
                    </div>
    </div>
    <div id="test1"></div>
</body>
</html>
